package com.atguigu.gulimall.order.vo;

import com.atguigu.common.vo.MemberAddressVo;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public class ConfirmVo {
    private List<MemberAddressVo> vos;//收获地址
    private List<OrderItemVo> itemVos; //所有选择的购物项
    //private Integer integration;//优惠价信息
    private BigDecimal total;//订单总额
    private BigDecimal price;//应付价格


    private Map<Long,Boolean> stocks;
    @Getter
    @Setter
    private String token;

    public Map<Long, Boolean> getStocks() {
        return stocks;
    }

    public void setStocks(Map<Long, Boolean> stocks) {
        this.stocks = stocks;
        for (OrderItemVo itemVo : itemVos) {
            Long skuId = itemVo.getSkuId();
            Boolean aBoolean = stocks.get(skuId);
            itemVo.setHashStock(aBoolean);
        }
    }

    public Integer getCount(){
        Integer i = 0;
        for (OrderItemVo itemVo : itemVos) {
            i+=itemVo.getCount();
        }
        return i;
    }

    public List<MemberAddressVo> getVos() {
        return vos;
    }

    public void setVos(List<MemberAddressVo> vos) {
        this.vos = vos;
    }

    public List<OrderItemVo> getItemVos() {
        return itemVos;
    }

    public void setItemVos(List<OrderItemVo> itemVos) {
        this.itemVos = itemVos;
    }

    public BigDecimal getTotal() {
        BigDecimal decimal = new BigDecimal("0");

        for (OrderItemVo itemVo : itemVos) {
            BigDecimal price = itemVo.getTotalPrice();//单个商品总价
            decimal = decimal.add(price);
        }
        return decimal;
    }

    public BigDecimal getPrice() {
        return getTotal();
    }

}
